package edu.isquen.init;

import edu.isquen.core.admin.model.Superuser;
import edu.isquen.core.admin.service.SuperuserService;
import edu.isquen.util.CommUtil;
import edu.isquen.util.factory.ServiceFactory;
import edu.isquen.web.exception.BaseException;

public class InitUserInfo implements InitInitialization {

	public void run() throws BaseException {
		try {
			SuperuserService service = (SuperuserService) ServiceFactory.createProcess(SuperuserService.class);
			if (service.doQuery().datas.size()<=0) {
				Superuser user = new Superuser();
				user.setId(CommUtil.getUUID());
				user.setName("Admin");
				user.setLoginno("admin");
				user.setLoginpwd(CommUtil.encodeToMD5("123456"));
				user.setSuperAdmin(true);
				user.setStatus(1);
				service.doCreate(user);
			}
		} catch (Exception e) {
			throw new BaseException(e.getMessage());
		}
	}

}
